<template>
	<view class="page-seller">
		<view class="seller-info">
			<view class="img">
				<image class="Img" :src="seller[0].logo" mode=""></image>
			</view>
			<view class="name">
				{{seller[0].sellerName}}
			</view>
			<view class="other-box">
				<view class="services">
					<text class="tit">地址&nbsp&nbsp</text>
					<text class="content">{{seller[0].address}}</text>
				</view>
				<view class="line"></view>
				<view class="delivery">
					<text class="tit">简介&nbsp&nbsp</text>
					<text class="content">&nbsp&nbsp{{seller[0].introduction}}</text>
				</view>
				<view class="line"></view>
			</view>
		</view>
		<!--买家评价-->
		<view class="comments">
			<view class="tit">
				<view class="text">
					买家评价（x条）
				</view>
				<view class="more text-arrow">
					全部
				</view>
			</view>
			<view class="content">
				<view class="item">
					<image class="img" src="../../static/images/business/002.png" mode=""></image>
					<view class="text1">
						手机用户0084
					</view>
					<view class="text2">
						5.0分 超满意
					</view>
					<view class="text2">
						【默认好评】通过平台担保交易买到一只泰迪
					</view>
				</view>
				<view class="item">
					<image class="img" src="../../static/images/business/002.png" mode=""></image>
					<view class="text1">
						手机用户0084
					</view>
					<view class="text2">
						5.0分 超满意
					</view>
					<view class="text2">
						【默认好评】通过平台担保交易买到一只泰迪
					</view>
				</view>
				<view class="item">
					<image class="img" src="../../static/images/business/002.png" mode=""></image>
					<view class="text1">
						手机用户0084
					</view>
					<view class="text2">
						5.0分 超满意
					</view>
					<view class="text2">
						【默认好评】通过平台担保交易买到一只泰迪
					</view>
				</view>
			</view>
		</view>

		<view class="sale">
			<view class="tit">
				<view class="text">
					 在售宠物({{pets.length}}种)
				</view>
			</view>
			<view class="waterfall">
				<waterfall :ComListSon="pets"></waterfall>
				<!-- <view v-for="(item, index) in pets" :key="index" class="waterfalls-flow-column"
					@click="goToDetail(item.goodsID)">
					{{item.goodsID}}
					{{item.goodsName}}
					{{item.price}}
				</view> -->
				
			</view>
		</view>
	
	</view>
</template>

<script>
	import axios from 'axios';
	import service from '../../utils/request.js';
	import waterfall from '../../components/waterFall/waterFall.vue';
	export default {
		data() {
			return {
				sellerID: null,
				seller: [],
				pets:[],
				imgUrl:''
			};
		},
		components: {
			waterfall
		},
		onLoad() {
			// 将 goodsID 转换为整数并保存到 data 中
			this.sellerID = uni.getStorageSync('sellerID')
			// 调用 getPetsData 方法时传递转换后的整数 goodsID
			this.getSellerData(this.sellerID);
			this.getSellerPetsData(this.sellerID);
		},
		methods: {
			goToDetail(goodsID) {
				uni.setStorageSync('goodsID', goodsID)
				uni.navigateTo({
			
					url: '/subpages/detail/detail?goodsID=${goodsID}'
				});
				console.log(typeof(goodsID))
			},
			async getSellerData(sellerID) {
				try {
					// 确认 goodsID 的类型是整数
					
					const response = await service.get('/seller/list/' + sellerID);
					this.seller = response.data;
					this.imgUrl=this.seller.logo;
					console.log('获取的数据:', response);
					console.log('Received goodsID:', this.sellerID);
				} catch (error) {
					console.error('获取数据失败:', error);
					console.log('Received goodsID:', this.sellerID);
				}
			},
			async getSellerPetsData(sellerID) {
				try {
					// 确认 goodsID 的类型是整数
					
					const response1 = await service.get('/pets/listBySellerID/' + sellerID);
					this.pets = response1.data;
					console.log('获取的数据:', response1);
					console.log('Received goodsID:', this.sellerID);
				} catch (error) {
					console.error('获取数据失败:', error);
					console.log('Received goodsID:', this.sellerID);
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	@use "seller";
</style>